<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数</title>
</head>
<body>
    <script>
        //1.JS通过function关键字来定义函数
        function f1(){
          console.log('你好!星期五!')
        }
        f1();//调用函数
        f1();

        function f2(n) {
          console.log('形参值:'+n);
        }
        f2(666);
        f2("下午好!");

        function f3(a,b) {
          console.log(a);
          console.log(b);
          console.log(a+b);
        }
        f3(2,3);
        f3(2);
        f3(3,4,5);

        function f4() {
          console.log(arguments)
        }
        f4(50);
        f4(50,60);
        f4(50,60,70);

        function f5(x,y) {
            return x+y;
        }
        console.log(f5(2,3));
        let res = f5(2,3);
        console.log(res);

        //第二种函数声明方式
        let f6 = function () {
            console.log('第二种')
        }
        f6();
        console.log(f6);
        console.log(typeof(f6));

        //第三种函数声明方式
        let f7 = new Function("name","age","console.log('方法体');return age;");
        console.log(f7('小明',18));
    </script>
</body>
</html>